﻿<%= stylesheet_link_tag 'coderay' %>
<%= stylesheet_link_tag 'pagination' %>

<% if logged_in? %>
<div style="float: right;">
  <%= link_to image_tag("/images/forum/new_post.gif"), new_post_path(:forum_id => @post.forum.id) %>
  <%= link_to image_tag("/images/forum/new_comment.gif"), new_comment_path(:post_id => @post.id) %>
</div>
<% end %>
<br/>

<%= link_to "BeyondRails论坛", HOME + "/forums" %> » <%= link_to @post.forum.title, forum_path(@post.forum) %> » <%= @post.title %>
<br/>
<h3><%= link_to @post.title, post_path(@post) %></h3>
<table cellspacing="0" cellpadding="0" class="forum">
	<tr>
		<td style="width: 150px; vertical-align: top;"><%= @post.user.login %></td>
		<td>
			发表于 <%= @post.created_at.strftime("%Y-%m-%d %H:%M") %> 
			Tag: <%= @post.tag_list.map{|tag|link_to(tag, tag_path(tag))}.join(', ') %>
		</td>
	</tr>
	<tr>
		<td style="vertical-align: top;">
			<%= link_to image_tag(@post.user.profile && @post.user.profile.avatar_path ? @post.user.profile.avatar_path : SysConfig::SYS_DEFAULT_AVATAR), "http://#{@post.user.login}.beyondrails.com" %>
		</td>
		<td style="vertical-align: top;">
			<%= bbcode2html @post.content %>
		</td>
	</tr>
	<% if logged_in? && current_user.id == @post.user.id %>
	<tr>
		<td colspan="2" style="text-align: right">
			<%= link_to "编辑", edit_post_path(@post) %>
		</td>
	</tr>
	<% end %>
	<% @comments.each do |c| %>
		<tr>
			<td style="width: 150px; vertical-align: top;"><%= c.user.login %></td>
			<td>发表于 <%= c.created_at.strftime("%Y-%m-%d %H:%M") %></td>
		</tr>
		<tr>
			<td style="vertical-align: top;">
				<%= link_to image_tag(c.user.profile && c.user.profile.avatar_path ? c.user.profile.avatar_path : SysConfig::SYS_DEFAULT_AVATAR), "http://#{c.user.login}.beyondrails.com" %>
			</td>
			<td style="vertical-align: top;">
				<%= bbcode2html c.content %>
			</td>
		</tr>
		<% if logged_in? && current_user.id == c.user.id %>
		<tr>
			<td colspan="2" style="text-align: right">
				<%= link_to "编辑", edit_comment_path(c) %>
			</td>
		</tr>
		<% end %>
	<% end %>
</table>

<%= will_paginate @comments, :class => "flickr_pagination" %>